﻿package game.ui {
	import game.objects.GameObject;
	
	public class MouseHelp extends GameObject {
		
		private var text:Text;
		
		public function MouseHelp(str:String):void {
			text = new Text;
			text.setFormat("size", 10);
			text.setFormat("color", 0xbbbbbb);
			text.set(str, null, false);
			addChild(text);
			text.x = 5;
			text.y = 3;
			
			this.graphics.clear();
			this.graphics.beginFill(0x111111, 0.9);
			this.graphics.drawRoundRect(0, 0, text.width+text.x*2, text.height+text.y*2, 10, 10);
			this.graphics.endFill();
			
			animate('alpha', 0, 1, 0.2);
		}
		
		public function close():void {
			this.name = "instance_"+String(Math.random());
			animate ( 'alpha', this.alpha, 0, 0.2, remove );
		}
		
		private function remove(e) {
			this.parent.removeChild(this);
		}
		
		public function move(_x:Number, _y:Number):void {
			this.x = _x;
			this.y = _y;
		}
	}
}